package com.atguigu.redisdemo;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class MyRedisCluster {
    public static void main(String[] args) {
        //1.1线程池配置
        GenericObjectPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(5);
        config.setMinIdle(2);
        config.setMaxTotal(10);
        //1.2配置集群ip和端口
        Set<HostAndPort> set = new HashSet<>();
        set.add(new HostAndPort("192.168.1.102",6379));
        //1.创建集群对象,传入集群地址和线程池配置
        JedisCluster cluster = new JedisCluster(set, config);
        cluster.set("k1","v3213123123");
        System.out.println(cluster.get("k1"));
    }
}
